Conditions | 8 |
Paths | 8 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 8.1515 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | "use strict"; |
||
8 | 1 | const normalize = (meta = {}, level = 0) => { |
|
9 | 185 | if (level++ < 5) { |
|
10 | 185 | if (Array.isArray(meta)) { |
|
11 | return meta.map(metaData => normalize(metaData, level)); |
||
12 | 185 | } else if (meta instanceof Request) { |
|
13 | return transformers.request(meta); |
||
14 | 185 | } else if (meta instanceof Response) { |
|
15 | 7 | return transformers.response(meta); |
|
16 | 178 | } else if (meta instanceof Object) { |
|
17 | 66 | const newObject = {}; |
|
18 | 66 | for (let metaKey in meta) { |
|
19 | 169 | if (meta.hasOwnProperty(metaKey)) { |
|
20 | 169 | newObject[metaKey] = normalize(meta[metaKey], level); |
|
21 | } |
||
22 | } |
||
23 | |||
24 | 66 | return newObject; |
|
25 | } |
||
26 | } |
||
27 | |||
28 | 112 | return meta; |
|
29 | }; |
||
30 | |||
64 |